<include file="public@header"/>
<style>
    .layui-form-pane .layui-form-checkbox {
        margin: 0;
    }
</style>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}" class="layui-col-md12" style="margin-bottom: 10px">
        <div class="layui-input-inline">
            <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
            <input class="layui-input" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
                   style="width: 200px;" title="图片名称">
        </div>
        <div class="layui-form-mid layui-word-aux" style="padding: 0 !important;">
            <img id="photo-{id}-preview" src="{url}" style="height:35px;width: 35px;padding-left: 10px;"
                 onclick="imagePreviewDialog(this.src);">
            <a class="nobtn"  href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
            <a class="nobtn"  href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
        </div>
    </li>
</script>
<script type="text/html" id="files-item-tpl">
    <li id="saved-file{id}" class="layui-col-md12" style="margin-bottom: 10px">
        <div class="layui-input-inline">
            <input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
            <input class="layui-input" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
                   style="width: 200px;" title="文件名称">
        </div>
        <div class="layui-form-mid layui-word-aux" style="margin-left: 10px;">
            <a class="nobtn"  id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
            <a class="nobtn"  href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
            <a class="nobtn"  href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
        </div>
    </li>
</script>
</head>
<body>
<div class="layui-fluid">
    <form action="{:url('AdminPage/editPost')}" method="post" class="layui-form layui-form-pane layui-row layui-col-space15 js-ajax-form">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-tab layui-tab-brief">
                    <ul class="layui-tab-title">
                        <if condition="input('type') == 'manage'">
                            <li><a href="{:url('AdminPage/indexManage')}">链接管理</a></li>
                            <elseif condition="input('type') == 'protocol'">
                                <li><a href="{:url('AdminPage/indexProtocol')}">协议管理</a></li>
                                <else/>
                                <li><a href="{:url('AdminPage/index')}">所有页面</a></li>
                        </if>
                        <li class="layui-this">编辑页面</li>
                    </ul>
                </div>
                <div class="layui-card-body">
                    <div class="layui-form-item" style="display: none'">
                        <label class="layui-form-label">类型</label>
                        <div class="layui-input-inline">
                            <select class="layui-input" name="post[type]">
                                <option value="0" <if condition="$post['type'] eq 0 ">selected</if>>单页面</option>
                                <option value="2" <if condition="$post['type'] eq 2 ">selected</if>>关于我们</option>
                            </select>
                        </div>
                    </div>
                    <input class="layui-input" type="hidden" name="post[type]" value="2"/>

                    <div class="layui-form-item">
                        <div class="layui-form-label">标题<span class="form-required">*</span></div>
                        <div class="layui-input-block">
                            <input type="hidden" name="post[id]" value="{$post.id}">
                            <input class="layui-input" type="text" style="width: 400px;" name="post[post_title]"
                                   required
                                   value="{$post.post_title}" placeholder="请输入标题"/>
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: none;">
                        <div class="layui-form-label">别名</div>
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="post[post_alias]"
                                   value="{$post.post_alias}" placeholder="请输入别名"/>
                        </div>
                        <div class="layui-form-mid layui-word-aux">用于美化url链接</div>
                    </div>
                    <div class="layui-form-item" style="display: none;">
                        <div class="layui-form-label">关键词</div>
                        <div class="layui-input-inline">
                            <input class="layui-input" type="text" name="post[post_keywords]"
                                   value="{$post['post_keywords']}" placeholder="请输入关键字">
                        </div>
                        <div class="layui-form-mid layui-word-aux">多关键词之间用空格隔开</div>
                    </div>
                    <div class="layui-form-item layui-form-text" style="display: none;">
                        <div class="layui-form-label">摘要</div>
                        <div class="layui-input-block">
                            <textarea class="layui-textarea" name="post[post_excerpt]" style="height: 50px;">{$post.post_excerpt}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <div class="layui-form-label">内容</div>
                        <div class="layui-input-block">
                            <script type="text/plain" id="content" name="post[post_content]">{$post.post_content}</script>
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: none;">
                        <div class="layui-form-label">相册</div>
                        <div class="layui-input-block">
                            <ul id="photos" class="pic-list list-unstyled form-inline layui-col-md4">
                                <notempty name="post.more.photos">
                                    <foreach name="post.more.photos" item="vo">
                                        <php>$img_url=cmf_get_image_preview_url($vo['url']);</php>
                                        <li id="saved-image{$key}" class="layui-col-md12" style="margin-bottom: 10px">
                                            <div class="layui-input-inline">
                                                <input id="photo-{$key}" type="hidden" name="photo_urls[]" value="{$vo.url}">
                                                <input class="layui-input" id="photo-{$key}-name" type="text"
                                                       name="photo_names[]"
                                                       value="{$vo.name|default=''}" style="width: 200px;" title="图片名称">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux" style="padding: 0 !important;">
                                                <img id="photo-{$key}-preview"
                                                     src="{:cmf_get_image_preview_url($vo['url'])}"
                                                     style="height:35px;width: 35px;padding-left: 10px;"
                                                     onclick="parent.imagePreviewDialog(this.src);">
                                                <a class="nobtn"  href="javascript:uploadOneImage('图片上传','#photo-{$key}');">替换</a>
                                                <a class="nobtn"  href="javascript:(function(){$('#saved-image{$key}').remove();})();">移除</a>
                                            </div>
                                        </li>
                                    </foreach>
                                </notempty>
                            </ul>
                            <div class="layui-col-md4" style="margin-left: 15px">
                                <a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
                                   class="layui-btn layui-btn-primary" style="border: 1px dashed #e2e2e2;"><i class="layui-icon" style="color: #2d8cf0;"></i>选择图片</a>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: none;">
                        <div class="layui-form-label">附件</div>
                        <div class="layui-input-block">
                            <ul id="files" class="pic-list list-unstyled form-inline layui-col-md4">
                                <notempty name="post.more.files">
                                    <foreach name="post.more.files" item="vo">
                                        <php>$file_url=cmf_get_file_download_url($vo['url']);</php>
                                        <li id="saved-file{$key}" class="layui-col-md12" style="margin-bottom: 10px">
                                            <div class="layui-input-inline">
                                                <input id="file-{$key}" type="hidden" name="file_urls[]"
                                                       value="{$vo.url}">
                                                <input class="layui-input" id="file-{$key}-name" type="text"
                                                       name="file_names[]"
                                                       value="{$vo.name}" style="width: 200px;" title="图片名称">
                                            </div>
                                            <div class="layui-form-mid layui-word-aux" style="margin-left: 10px;">
                                                <a class="nobtn" id="file-{$key}-preview" href="{$file_url}" target="_blank">下载</a>
                                                <a class="nobtn" href="javascript:uploadOne('文件上传','#file-{$key}','file');">替换</a>
                                                <a class="nobtn" href="javascript:(function(){$('#saved-file{$key}').remove();})();">移除</a>
                                            </div>
                                        </li>
                                    </foreach>
                                </notempty>
                            </ul>
                            <div class="layui-col-md4" style="margin-left: 15px">
                                <a href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl','file');"
                                   class="layui-btn layui-btn-primary" style="border: 1px dashed #e2e2e2;"><i class="layui-icon" style="color: #2d8cf0;"></i>选择文件</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md3" style="display: none;">
            <div class="layui-card">
                <div class="layui-card-header">其它</div>
                <div class="layui-card-body">
                    <div class="layui-form-item">
                        <div class="layui-form-label">缩略图</div>
                        <div class="layui-input-block">
                            <div class="layui-col-md12">
                                <input type='hidden' name='post[more][thumbnail]' id='thumbnail'
                                       value="{$post.more.thumbnail|default=''}">
                                <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
                                    <if condition="empty($post['more']['thumbnail'])">
                                        <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                             id='thumbnail-preview'
                                             width='135' height='135' style='cursor: pointer'/>
                                        <else/>
                                        <img src="{:cmf_get_image_preview_url($post['more']['thumbnail'])}"
                                             id='thumbnail-preview'
                                             width='135' height='135' style='cursor: hand'/>
                                    </if>
                                </a>
                                <div class="layui-col-md12" style="margin-top: 10px">
                                    <input type="button" class="layui-btn layui-btn-sm layui-btn-normal"
                                           onclick="$('#thumbnail-preview').attr('src','__TMPL__/public/assets/images/default-thumbnail.png');$('#thumbnail').val('');return false;"
                                           value="取消图片">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-form-label">发布时间</div>
                        <div class="layui-input-block">
                            <input class="layui-input js-bootstrap-datetime" type="text" name="post[published_time]"
                                   value="{:date('Y-m-d H:i',$post['published_time'])}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-form-label">摸板</div>
                        <div class="layui-input-block">
                            <select class="layui-input" name="post[more][template]" id="more-template-select">
                                <option value="">请选择模板</option>
                                <foreach name="page_theme_files" item="vo">
                                    <php>$value=preg_replace('/^portal\//','',$vo['file']);</php>
                                    <option value="{$value}">{$vo.name} {$vo.file}.html</option>
                                </foreach>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md3" style="display:none;">
            <div class="layui-card">
                <div class="layui-card-header">状态</div>
                <div class="layui-card-body">
                    <php>
                        $status_yes=$post['post_status']==1?"checked":"";
                    </php>
                    <input type="checkbox" name="post[post_status]" value="1" title="发布" lay-skin="primary" {$status_yes}>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
                <div class="layui-footer" style="left: 0;">
                    <button type="submit" class="layui-btn js-ajax-submit">{:lang('SAVE')}</button>
                    <if condition="input('type') == 'manage'">
                        <a class="layui-btn layui-btn-primary" href="{:url('AdminPage/indexManage')}">{:lang('BACK')}</a>
                        <elseif condition="input('type') == 'protocol'">
                            <a class="layui-btn layui-btn-primary" href="{:url('AdminPage/indexProtocol')}">{:lang('BACK')}</a>
                            <else/>
                            <a class="layui-btn layui-btn-primary" href="{:url('AdminPage/index')}">{:lang('BACK')}</a>
                    </if>
                </div>
            </div>
        </div>
    </form>
</div>
<include file="public@script"/>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js?t=1622451089"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {

        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }

        $('#more-template-select').val("{$post.more.template|default=''}");
    });
</script>
</body>
</html>